<template>
  <div>
    <navbar>
      <div slot="left" class="back" @click="back">
        <img src="../../../assets/img/detailNav/back.svg" alt="">
      </div>
      <div slot="center" class="title">
        <div v-for="(item,index) in titles" class="title-item" @click="itemclick(index)" :class="{active:index == currentindex}">{{item}}</div>
      </div>
    </navbar>
  </div>
</template>

<script>
  import navbar from "../../../components/common/navbar/Navbar.vue"
  export default{
    components:{
      navbar
    },
    data:function(){
      return{
        titles:['商品','参数','评论','推荐'],
        currentindex:0
      }
    },
    methods:{
      itemclick(index){
        this.currentindex = index
        this.$emit('itemclick',index)
      },
      back(){
        this.$router.go(-1)
      }
    }
  }
</script>

<style>
  .title{
    display: flex;
  }
  .title-item{
    flex: 1;
  }
  .active{
    color: #ff5777;
  }
  .back img{
    margin: 10px 5px;
  }
</style>
